/**
* 左边菜单
*/
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      智慧教育
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          menuname: '系统管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-cat-skuQuery',
              menuname: '用户管理',
              hasThird: 'N',
              url: 'system/user',
              menus: null
            },
            {
              menuid: 3,
              icon: 'icon-cat-skuQuery',
              menuname: '角色管理',
              hasThird: 'N',
              url: 'system/role',
              menus: null
            },
            {
              menuid: 4,
              icon: 'icon-cat-skuQuery',
              menuname: '菜单管理',
              hasThird: 'N',
              url: 'system/module',
              menus: null
            },
            {
              menuid: 5,
              icon: 'icon-cat-skuQuery',
              menuname: '权限管理',
              hasThird: 'N',
              url: 'system/permission',
              menus: null
            }
          ]
        },
        {
          menuid: 6,
          icon: 'li-icon-dingdanguanli',
          menuname: '课程管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 8,
              icon: 'icon-order-manage',
              menuname: '免费课程管理',
              hasThird: 'N',
              url: 'class/freeclass',
              menus: null
            },
            {
              menuid: 10,
              icon: 'icon-order-manage',
              menuname: '直播管理',
              hasThird: 'N',
              url: 'class/live',
              menus: null
            },
            {
              menuid: 11,
              icon: 'icon-order-manage',
              menuname: '类别管理',
              hasThird: 'N',
              url: 'class/classify',
              menus: null
            }
          ]
        },
        {
          menuid: 12,
          icon: 'icon-order-manage',
          menuname: '资源中心',
          hasThird: 'N',
          url: null,
          menus: [
            {
              menuid: 7,
              icon: 'icon-order-manage',
              menuname: '资源管理',
              hasThird: 'N',
              url: 'class/video',
              menus: null
            },
          ]
        },

        {
          menuid: 16,
          icon: 'li-icon-dingdanguanli',
          menuname: '教师管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 17,
              icon: 'icon-order-manage',
              menuname: '讲师管理',
              hasThird: 'N',
              url: 'teacher'
            },
            {
              menuid:41,
              icon: 'icon-order-manage',
              menuname: '添加讲师',
              hasThird: 'N',
              url: 'teacher/create'
            }
          ]
        },{
          menuid: 40,
          icon: 'icon-order-manage',
          menuname: '学生管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 39,
              icon: 'icon-order-manage',
              menuname: '学生管理',
              hasThird: 'N',
              url: 'student',
              menus: null
            }
          ]
        },
        {
          menuid: 18,
          icon: 'li-icon-dingdanguanli',
          menuname: '订单管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 19,
              icon: 'icon-order-manage',
              menuname: '订单管理',
              hasThird: 'N',
              url: 'pay/order',
              menus: null
            },
            {
              menuid: 20,
              icon: 'icon-order-manage',
              menuname: '营销管理',
              hasThird: 'N',
              url: 'pay/list',
              menus: null
            }
          ]
        },
        {
          menuid: 21,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '通知管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 22,
              icon: 'icon-provider-manage',
              menuname: '通知管理',
              hasThird: 'N',
              url: 'notice',
              menus: null
            }
          ]
        },
        {
          menuid: 23,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '系统监控',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 24,
              icon: 'icon-provider-manage',
              menuname: '操作日志',
              hasThird: 'N',
              url: 'opt/log',
              menus: null
            },
            {
              menuid: 25,
              icon: 'icon-provider-manage',
              menuname: '登录日志',
              hasThird: 'N',
              url: 'login/log',
              menus: null
            },
            {
              menuid: 26,
              icon: 'icon-provider-manage',
              menuname: '缓存监控',
              hasThird: 'N',
              url: 'monitor/cache',
              menus: null
            },
            {
              menuid: 35,
              icon: 'icon-provider-manage',
              menuname: '服务监控',
              hasThird: 'N',
              url: 'monitor/server',
              menus: null
            }
            ]
        },
        {
          menuid: 29,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '系统接口',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 30,
              icon: 'icon-provider-manage',
              menuname: '系统接口',
              hasThird: 'N',
              url: 'doc',
              menus: null
            }
          ]
        }, {
          menuid: 31,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '图表',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 32,
              icon: 'icon-provider-manage',
              menuname: '数据可视化',
              hasThird: 'N',
              url: 'charts/statistics',
              menus: null
            }
          ]
        },
        {
          menuid: 36,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '关于我',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 38,
              icon: 'icon-provider-manage',
              menuname: '关于我',
              hasThird: 'N',
              url: 'about',
              menus: null
            }
          ]
        }
      ],
    }
    this.allmenu = res.data
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 30px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 30px;
  margin-left: 10px;
}
</style>
